<template>
	<scroll-view class="backview" bounces="false">
		<lexiconNavVue title="英语词库" />
		<view class="top-menu">
		</view>
		<scroll-view class="words-scroll" :style="{ height: scrollHeight + 'px'}" scroll-y
			:scroll-with-animation='true'>
			<view class="lexIcon-back">
				<block v-for="(item,index) in productList" :key="index">
					<lexIconHomeCell :courseData="item" rightStr="GO" :dataIndex="index" @wordClicked="wordClicked">
					</lexIconHomeCell>
				</block>
			</view>
		</scroll-view>
		<popPromptBox v-if="showPromptbox" :msg="PromptMsg" @confirm="hidePromptbox"></popPromptBox>
	</scroll-view>
</template>

<script>
	import lexIconHomeCell from '../../components/lexIconCom/lexIconHomeCell.vue'
	export default {
		components: {
			lexIconHomeCell
		},
		data() {
			return {
				showPromptbox: false,
				scrollHeight: uni.getSystemInfoSync().windowHeight - 49,
				productList: []
			}
		},
		onLoad() {
			this.getWordListData();
		},
		onReady() {
			const that = this
			uni.createSelectorQuery().select('.top-menu').boundingClientRect(rect => {
				that.scrollHeight = uni.getSystemInfoSync().windowHeight - rect.bottom;
			}).exec();
		},
		methods: {
			hidePromptbox() {
				this.showPromptbox = false;
			},
			getWordListData() {
				this.$http.getSysDictDataList({
					dictType: 'pczx_champion_thesaurus'
				}).then(res => {
					if (res.code === 200) {
						var productList = [];
						for (let i = 0; i < res.data.length; i++) {
							var item = res.data[i];
							if (item.dictValue == 'individual_champion_thesaurus' || item.dictValue == 'itso_champion_thesaurus') {
								productList.push(item);
							}
						}
						this.productList = productList;
					}
				})
			},
			wordClicked(selecrIndex) {
				console.log('selecrIndex', selecrIndex)
				const selectData = this.productList[selecrIndex];
				console.log('selectData', selectData)
				if (selectData.dictValue == 'baby_thesaurus') { // baby词库
					this.showPromptbox = true;
					this.PromptMsg = '暂未开放，敬请期待';
					// uni.showToast({
					// 	title: '开发中！',
					// 	icon: 'none',
					// 	duration: 2000
					// })
				} else if (selectData.dictValue == 'reserve_package') { // 全方位备赛词库
					uni.navigateTo({
						url:'/pages/planBee/wordClickThesaurusGroupList'
					})
				} else if (selectData.dictValue == 'powerword_thesaurus') {
					this.showPromptbox = true;
					this.PromptMsg = '暂未开放，敬请期待';
				} else {
					uni.navigateTo({
						url: '/pages/lexicon/lexiconList?wordModel=' + JSON.stringify(selectData),
					})
				}

			},
			getProductInfo(selectData) {
				var formData = {};
				formData.flag = selectData.dictValue;
				formData.activityType = this.$statusCode.activityType;
				this.$http.getAppletsProduct(formData).then(res => {
					console.log('getAppletsProduct', res)
					if (res.code === 200) {
						var productData = res.data;
						if (productData.isExpired == 1) {
							uni.navigateTo({
								url: '/pages/lexicon/babyLexIcon?wordModel=' + JSON.stringify(selectData)
							})
						} else {
							productData.type = 'words';
							this.productData = productData;
							// this.setData({
							// 	showEnterCodetbox: true,
							// 	productData: productData
							// })
						}
					}
				})
			}
		}
	}
</script>

<style lang="less">
	.backview {
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		top: 0;
		right: 0;
		background: #fff7dd;
	}

	.top-menu {
		width: 90%;
		margin-left: 5%;
		height: 5px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
	}

	.menuclass {
		width: 90px;
		height: 28px;
		margin-top: 8px;
		line-height: 28px;
		border-radius: 5px;
		background: #000;
		font-size: 13px;
		font-weight: 900;
		text-align: center;
		color: white;
	}

	.activeClass {
		width: 90px;
		height: 28px;
		line-height: 28px;
		border-radius: 5px;
		background: #e7e7e7;
		font-size: 13px;
		font-weight: 900;
		text-align: center;
		color: black;
		box-shadow: 0px 5px 0px 0px rgba(204, 204, 204, 1);
	}

	.lexIcon-back {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: 20px;
	}
</style>